package user;

import book.BookList;
import iooperation.*;

import java.util.Scanner;

public class NormalUser extends User {
    public NormalUser(String name) {
        super(name);
       //创建一个接口数组：
       //为对象数组赋值,只有在创建数组时，才可为数组整体赋值！！！
        this.iOperations = new IOperation[]{
                new SearchOperation(),
                new SearchOperation(),
                new BorrowOperation(),
                new ReturnOperation(),
                new ExitOperation()
        };
    }
    public void dooperation(int choice, BookList bookList){
        //根据choice，调用相应的业务类对象
        this.iOperations[choice].work(bookList);
    }


    public int  menu(){
        System.out.println("*****************************");
        System.out.println("******普通用户菜单*******");
        System.out.println("******1. 查找图书**********");
        System.out.println("******2. 借阅图书***********");
        System.out.println("******3. 归还图书**********");
        System.out.println("******4. 退出系统**********");
        System.out.println("*****************************");
        System.out.println("请选择你要执行的操作！");
        return   new Scanner(System.in).nextInt();
    }
}
